package com.apps.gomdiem.activity;

import java.util.ArrayList;

import com.apps.gomdiem.R;
import com.apps.gomdiem.adapter.CatalogChoiceMenuAdapter;
import com.apps.gomdiem.model.ListTempMenu;
import com.apps.gomdiem.model.MenuList;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class CatalogChoiceMenu extends Activity {
	ArrayList<ListTempMenu> listMenu = new ArrayList<ListTempMenu>();
	int count;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_catalog_choice_menu);
		CatalogChoiceMenuAdapter adapter = new CatalogChoiceMenuAdapter(
				menuTempList(), getApplicationContext());
		ListView listCatalog = (ListView) findViewById(R.id.listCatalog);
		listCatalog.setAdapter(adapter);
		for (int i = 0; i < listMenu.size(); i++) {
			count+=listMenu.get(i).getPrice();
		}
		TextView sumPrice = (TextView)findViewById(R.id.txtCount);
		sumPrice.setText(Integer.toString(count));
		Button submit =(Button)findViewById(R.id.btnSubmit);
		submit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
					finish();
			}
		});
	}

	public ArrayList<ListTempMenu> menuTempList() {
		String[] namMenu = { "Sinh To Bo", "Sinh To Dau", "Cafe Sua" };
		int[] quantity = { 2, 1, 4 };
		int[] price = { 40000, 20000, 60000 };

//		ArrayList<ListTempMenu> listMenu = new ArrayList<ListTempMenu>();
		for (int i = 0; i < namMenu.length; i++) {
			ListTempMenu mListMenu = new ListTempMenu(namMenu[i], quantity[i],price[i]);
			listMenu.add(mListMenu);
			
		}
		

		return listMenu;

	}
}
